#ifndef AVALON_CONNECTION_HPP
#define AVALON_CONNECTION_HPP
#include <boost/function.hpp>
#include "Avalon/Base/Out.hpp"
#include "Avalon/IO/IO.hpp"

namespace Avalon {
namespace IO {

  /*! \class Connection
   *  \brief Interface for a connection based IO resource.
   */
  class Connection {
    public:

      //! Called when the Connection closes.
      typedef boost::function<void ()> ClosedSlot;

      virtual ~Connection();

      //! Returns <code>true</code> iff the Connection is open.
      virtual bool IsOpen() const = 0;

      //! Closes the existing Connection.
      virtual void Close() = 0;

      //! Sets the ClosedSlot.
      /*!
        \param slot The slot to connect.
        \param isOpen <code>true</code> iff the Connection is open.
      */
      virtual void SetClosedSlot(const ClosedSlot& slot, Out<bool> isOpen) = 0;
  };
}
}

#endif // AVALON_CONNECTION_HPP
